$(document).ready(function(){
	cw.common.getUserSession(loadT_CHECK_INFO);
})

//载入资产盘点信息
function loadT_CHECK_INFO(){
	var CHECK_NO=$("#CHECK_NO").val();
	if(CHECK_NO==undefined)CHECK_NO="";
	var CHAGE_STATUS=$("#CHAGE_STATUS").val();
	var url = cw.common.path + '/json?action=QUERY_T_CHECK_INFOBY_PAGER_ACTION';
	url += "&CHECK_NO="+CHECK_NO+"&CHAGE_STATUS="+CHAGE_STATUS;
	var xmlname = "T_CHECK_INFO";
	var pagePanel='#T_CHECK_INFO_pager';
	var result='#T_CHECK_INFO_LIST';
	var pageSize=10;
	var defaultHtml='<li><em style="text-align: center;width:100%">没有搜索到您要查询的数据...</em></li>';
	cw.common.changePage(url,pageSize,xmlname,result,fn_queryloadT_CHECK_INFOLLIST,pagePanel,defaultHtml);
}
var fn_queryloadT_CHECK_INFOLLIST = function(obj,result,i){
	var status = obj.CHAGE_STATUS;
	if(status=='1')status="盘点中";
	else status="盘结";
	var str='<li id="bar_'+obj.CHECK_NO+'">';
	str+='<em style="width: 9%; text-align: center;">'+obj.CHECK_NO+'</em>';
	str+='<em style="width: 9%; text-align: center;">'+cw.common.toChar(obj.CHANGE_BEGIN_DATE,'yyyy-mm-dd')+'</em>';
	str+='<em style="width: 9%; text-align: center;">'+cw.common.toChar(obj.CHANGE_END_DATE,'yyyy-mm-dd')+'</em>';
	str+='<em style="width: 9%; text-align: center;">'+status+'</em>';
	str+='<em style="width: 9%; text-align: center;">'+obj.CHENG_BEFULLOF+'</em>';
	str+='<em style="width: 9%; text-align: center;">'+obj.CHENG_LOSE+'</em>';
	str+='<em style="width: 9%; text-align: center;">'+obj.BEFULLOF_LOSE+'</em>';
	str+='<em style="width: 9%; text-align: center;">'+obj.PERSON_NAME+'</em>';
	str+='<em style="width: 15%; text-align: center;">';
	str+='<a href="editDetail.html?CHECKID='+obj.ID+'">修改</a>&nbsp;&nbsp;&nbsp;';
	str+='<a href="javascript:delCheck(\''+obj.ID+'\',\''+obj.CHECK_NO+'\')">删除</a>&nbsp;&nbsp;&nbsp</em>';
	str+='</li>';
	$(result).append(str);
}
//删除
var delCheck = function(id,check_no){
	
	if(!confirm("确认要删除吗？")){
		return;
	}
	
	var url = cw.common.path + '/json?action=DELETE_T_CHECK_INFO_ACTION&ID='+id;
	$.post(url,{},function(data){
		if(data.success){
			$("#bar_"+check_no).remove();
			alert("删除成功！");
		}
		else{
			alert(data.errors.errmsg);
		}
	},'json');
}
var download =function(id,status){
	
	if(status=='2'){
		alert("该盘点单已盘点，不能再下载盘点资产清单!");
	}
}
var upload =function(id,status){
	
	if(status=='2'){
		alert("该盘点单已盘点，不能再上载盘点资产清单!");
	}
	
	
}